package com.blog.test.decorator;


/**
 * 装饰模式
 * @author user
 *
 */
public interface ICar {
	void move();
}


class Car implements ICar {

	@Override
	public void move() {
		System.err.println("陆地上跑");
	}
	
}

class SuperCar implements ICar {
	
	protected ICar car;
	
	public SuperCar(ICar car) {
		this.car=car;
	} 
	
	@Override
	public void move() {
		car.move();
	}
	
}

class FlyCar extends  SuperCar {

	public FlyCar(ICar car) {
		super(car);
	}
	
	public void fly() {
		super.move();
		System.err.println("天上飞");
	} 
	
}
class WaterCar extends  SuperCar {

	public WaterCar(ICar car) {
		super(car);
	}
	
	public void fly() {
		super.move();
		System.err.println("水里游");
	} 
	
}

class AICar extends  SuperCar {

	public AICar(ICar car) {
		super(car);
	}
	
	public void fly() {
		super.move();
		System.err.println("自动走");
	} 
	
}
